package com.nizi.wordoperate.controller;

import com.nizi.wordoperate.utils.GenerateWord;
import com.nizi.wordoperate.utils.ReadExcelXlsx;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/api")
public class ModifyController {
    @ResponseBody
    @RequestMapping(value = "/modify/{path}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public String modifyContract(HttpServletRequest request, @PathVariable(value = "path") String path) {
        try {
            List<Map<String, Object>> list = ReadExcelXlsx.ReadExcelFinal(path);
            list.forEach(map -> {
                        try {
                            //GenerateWord.CreatWordByModel("D:/三月.doc", map, "D:/"+map.get("name")+map.get("age")+".doc");
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
